# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=smbexec
pkgver=59.a54fc14
pkgrel=11
epoch=2
groups=('blackarch' 'blackarch-scanner' 'blackarch-recon' 'blackarch-fuzzer'
        'blackarch-exploitation')
pkgdesc='A rapid psexec style attack with samba tools.'
arch=('any')
url='https://github.com/pentestgeek/smbexec'
license=('custom:unknown')
options=('!strip')
depends=('ruby' 'ruby-bundler' 'ruby-pkg-config' 'libxslt')
makedepends=('git' 'make')
source=("git+https://github.com/brav0hax/$pkgname.git")
#source=("git+https://github.com/pentestgeek/$pkgname.git")
sha512sums=('SKIP')
install="$pkgname.install"

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 README -t "$pkgdir/usr/share/doc/$pkgname/"

  cp -a * "$pkgdir/usr/share/$pkgname/"

  rm "$pkgdir/usr/share/$pkgname/README"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec ./$pkgname.rb "\$@"
EOF

  rm -rf "$pkgdir/usr/share/$pkgname/Gemfile.lock"

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

